<template>
   <div>
       <input :type="type" v-bind="$attrs" :value="value" @input="handleInput" />
   </div>
</template>
<script>
export default {
    name:'PInput',
    props:{
        value:{
            type:String
        },
        type:{
            type:String,
            default: 'text'
        }
    },
    inheriAttrs: false,
    methods:{
        handleInput($event){
            this.$emit('input',$event.target.value)
            const findParent = (parent)=>{
                while(parent){
                    if(parent.$options.name === 'PFoprmItem'){
                        break
                    }else{
                        parent = parent.$parent
                    }
                }
                return parent
            }
            const parent = findParent(this.$parent)
            if(parent){
                parent.$emit('validate')
            }
        }
    }
}
</script>
<style>
</style>